home *** CD-ROM | disk | FTP | other *** search
/ SGI Origin & Onyx2 Patches 1998 May / Origin and Onyx2 System Disk Patches May 1998.img / dist / patchSG0002839.idb / usr / include / sys / hwgraph.h.z / hwgraph.h
C/C++ Source or Header  |  1998-04-01  |  10KB  |  360 lines

  1. /**************************************************************************
  2.  *                                                                        *
  3.  *               Copyright (C) 1992-1995 Silicon Graphics, Inc.           *
  4.  *                                                                        *
  5.  *  These coded instructions, statements, and computer programs  contain  *
  6.  *  unpublished  proprietary  information of Silicon Graphics, Inc., and  *
  7.  *  are protected by Federal copyright law.  They  may  not be disclosed  *
  8.  *  to  third  parties  or copied or duplicated in any form, in whole or  *
  9.  *  in part, without the prior written consent of Silicon Graphics, Inc.  *
  10.  *                                                                        *
  11.  **************************************************************************/
  12. #ifndef _HWGRAPH_H
  13. #define _HWGRAPH_H
  14.  
  15. #ident    "$Revision: 1.32 $"
  16.  
  17. #if _KERNEL
  18. #include <sys/conf.h>
  19. #include <sys/graph.h>
  20. #include <sys/sysmacros.h>
  21.  
  22. /* Defines for dealing with fast "indexed" information associated with a vertex */
  23.  
  24. /* Reserve room in every vertex for 3 pieces of fast access indexed information */
  25. #define HWGRAPH_NUM_INDEX_INFO    3
  26.  
  27. #define HWGRAPH_DEVSW        0    /* {b,c}devsw for this device */
  28. #define HWGRAPH_CONNECTPT    1    /* connect point (parent) */
  29. #define HWGRAPH_FASTINFO    2    /* reserved for creator of vertex */
  30.  
  31. typedef int (*traverse_fn_t)(    vertex_hdl_t from,
  32.                 char **remainder_buf,
  33.                 vertex_hdl_t *to);
  34.  
  35. /*
  36.  * Interfaces to convert between graph vertex handles and dev_t's.
  37.  * Major number 0 is reserved for use by hwgraph; this allows the
  38.  * conversion between vhdl's and dev's to be a NULL conversion.
  39.  * That simplifies things for driver writers -- they can pass dev_t's
  40.  * directly to hwgraph interfaces.
  41.  *
  42.  *     ASSERT(HWGRAPH_MAJOR == 0);
  43.  *     ASSERT(GRAPH_VERTEX_NONE == NODEV);
  44.  */
  45. #define vhdl_to_dev(vhdl)    ((dev_t)(vhdl))
  46. #define dev_to_vhdl(dev)    ((vertex_hdl_t)(dev))
  47. #define dev_is_vertex(dev)    (emajor((dev_t)(dev)) == 0)
  48. #define HWGRAPH_STRING_DEV    makedev(0, 0)
  49. #define IS_HWGRAPH_STRING_DEV(x) ((dev_t)(x)==HWGRAPH_STRING_DEV)
  50.  
  51. /*
  52.  * Reserved edge_place_t values, used as the "place" parameter to edge_get_next.
  53.  * Every vertex in the hwgraph has up to 2 *implicit* edges.  There is an implicit
  54.  * edge called "." that points to the current vertex.  There is an implicit edge
  55.  * called ".." that points to the vertex' connect point.
  56.  */
  57. #define EDGE_PLACE_WANT_CURRENT GRAPH_EDGE_PLACE_NONE
  58. #define EDGE_PLACE_WANT_CONNECTPT 1
  59. #define EDGE_PLACE_WANT_REAL_EDGES 2
  60. #define HWGRAPH_RESERVED_PLACES 2
  61.  
  62.  
  63. /* Root of hwgraph */
  64. extern vertex_hdl_t hwgraph_root;
  65.  
  66.  
  67.  
  68. /* Operations on the hwgraph: init, summary_get, visit */
  69. extern graph_error_t hwgraph_summary_get(graph_attr_t *graph_attr);
  70.  
  71. extern graph_error_t hwgraph_vertex_visit(    int (*)(void *, vertex_hdl_t),
  72.                         void *arg,
  73.                         int *retval,
  74.                         vertex_hdl_t *end_handle);
  75.  
  76.  
  77.  
  78. /* Operations on VERTICES: create, destroy, clone, get_next, ref, unref */
  79.  
  80. extern graph_error_t hwgraph_vertex_create(vertex_hdl_t *vhdlp);
  81.  
  82. extern graph_error_t hwgraph_vertex_destroy(vertex_hdl_t vhdl);
  83.  
  84. extern graph_error_t hwgraph_vertex_clone(    vertex_hdl_t src,
  85.                         vertex_hdl_t *clone_vhdl_p);
  86.  
  87. extern graph_error_t hwgraph_vertex_get_next(    vertex_hdl_t *vhdlp,
  88.                         graph_vertex_place_t *place_p);
  89.  
  90. extern graph_error_t hwgraph_vertex_ref(vertex_hdl_t vhdl);
  91.  
  92. extern graph_error_t hwgraph_vertex_unref(vertex_hdl_t vhdl);
  93.  
  94.  
  95.  
  96.  
  97. /* Operations on EDGES: add, remove, get_next */
  98.  
  99. extern graph_error_t hwgraph_edge_add(    vertex_hdl_t from,
  100.                     vertex_hdl_t to,
  101.                     char *edge_name);
  102.  
  103. extern graph_error_t hwgraph_edge_remove(    vertex_hdl_t from,
  104.                         char *edge_name,
  105.                         vertex_hdl_t *old_to_p);
  106.  
  107. extern graph_error_t hwgraph_edge_get(    vertex_hdl_t from,
  108.                     char *edge_name,
  109.                     vertex_hdl_t *to_p);
  110.  
  111. extern graph_error_t hwgraph_edge_get_next(    vertex_hdl_t srcv,
  112.                         char *edge_name_buf,
  113.                         vertex_hdl_t *targetv,
  114.                         graph_edge_place_t *place_p);
  115.  
  116.  
  117.  
  118.  
  119. /* Special pre-defined edge labels */
  120. #define HWGRAPH_EDGELBL_HW     "hw"
  121. #define HWGRAPH_EDGELBL_DOT     "."
  122. #define HWGRAPH_EDGELBL_DOTDOT     ".."
  123.  
  124. /* 
  125. ** Operations on LABELLED INFORMATION: add, remove, replace, 
  126. ** get, get_next, export, unexport
  127. */
  128.  
  129. extern graph_error_t hwgraph_info_add_LBL(    vertex_hdl_t vhdl,
  130.                         char *info_name,
  131.                         arbitrary_info_t info);
  132.  
  133. extern graph_error_t hwgraph_info_remove_LBL(    vertex_hdl_t vhdl,
  134.                         char *info_name,
  135.                         arbitrary_info_t *old_info_p);
  136.  
  137. extern graph_error_t hwgraph_info_replace_LBL(    vertex_hdl_t vhdl,
  138.                         char *info_name,
  139.                         arbitrary_info_t new_info,
  140.                         arbitrary_info_t *old_info_p);
  141.  
  142. extern graph_error_t hwgraph_info_get_LBL(    vertex_hdl_t vhdl,
  143.                         char *info_name,
  144.                         arbitrary_info_t *info_p);
  145.  
  146. extern graph_error_t hwgraph_info_get_next_LBL(    vertex_hdl_t srcv,
  147.                         char *info_name_buf,
  148.                         arbitrary_info_t *info_p,
  149.                         graph_info_place_t *place_p);
  150.  
  151. extern graph_error_t hwgraph_info_export_LBL(    vertex_hdl_t vhdl,
  152.                         char *info_name,
  153.                         int export_info);
  154.  
  155. extern graph_error_t hwgraph_info_unexport_LBL(    vertex_hdl_t vhdl,
  156.                         char *info_name);
  157.  
  158.  
  159.  
  160.  
  161.  
  162. /*
  163. ** Operations on paths (strings): get_component, path_add,
  164. ** traverse, path_to_dev, device_add, add_link, device_get
  165. */
  166.  
  167. extern graph_error_t hwgraph_path_get_component(char *path,
  168.                         char *component,
  169.                         int *separator_length,
  170.                         int *component_length);
  171.  
  172. extern graph_error_t hwgraph_path_lookup(    vertex_hdl_t startv,
  173.                         char *path,
  174.                         vertex_hdl_t *endv_p,
  175.                         char **remainder_p);
  176.  
  177. extern graph_error_t hwgraph_path_add(    vertex_hdl_t from,
  178.                     char *path,
  179.                     vertex_hdl_t *newv_p);
  180.  
  181. extern graph_error_t hwgraph_traverse(    vertex_hdl_t from,
  182.                     char *path,
  183.                     vertex_hdl_t *to_p);
  184.  
  185. extern vertex_hdl_t hwgraph_path_to_vertex(char *path);
  186.  
  187. extern dev_t hwgraph_path_to_dev(char *path);
  188.  
  189. extern graph_error_t hwgraph_block_device_add(    vertex_hdl_t from,
  190.                         char *path,
  191.                         char *driver_prefix,
  192.                         vertex_hdl_t *bdev);
  193.  
  194. extern graph_error_t hwgraph_char_device_add(    vertex_hdl_t from,
  195.                         char *path,
  196.                         char *driver_prefix,
  197.                         vertex_hdl_t *cdev);
  198.  
  199. extern void hwgraph_device_add(    vertex_hdl_t from,
  200.                 char *path,
  201.                 char *driver_prefix,
  202.                 vertex_hdl_t *dev,
  203.                 vertex_hdl_t *block_dev,
  204.                 vertex_hdl_t *char_dev);
  205.  
  206. extern vertex_hdl_t hwgraph_block_device_get(vertex_hdl_t vhdl);
  207.  
  208. extern vertex_hdl_t hwgraph_char_device_get(vertex_hdl_t vhdl);
  209.  
  210.  
  211.  
  212.  
  213. /*
  214. ** set/get routines for indexed information and predefined labels:
  215. ** cdevsw, bdevsw, traverse routine
  216. */
  217. extern int hwgraph_cdevsw_set(    vertex_hdl_t vhdl,
  218.                 struct cdevsw *cdevsw);
  219.  
  220. extern struct cdevsw * hwgraph_cdevsw_get(vertex_hdl_t vhdl);
  221.  
  222. extern int hwgraph_bdevsw_set(    vertex_hdl_t vhdl,
  223.                 struct bdevsw *bdevsw);
  224.  
  225. extern struct bdevsw * hwgraph_bdevsw_get(vertex_hdl_t vhdl);
  226.  
  227. extern graph_error_t hwgraph_traverse_set(    vertex_hdl_t vhdl,
  228.                         traverse_fn_t func);
  229.  
  230. extern traverse_fn_t hwgraph_traverse_get(vertex_hdl_t vhdl);
  231.  
  232. extern void hwgraph_fastinfo_set(    vertex_hdl_t vhdl,
  233.                     arbitrary_info_t info);
  234.  
  235. extern arbitrary_info_t hwgraph_fastinfo_get(vertex_hdl_t vhdl);
  236.  
  237. extern void device_info_set(    dev_t device,
  238.                 void *info);
  239.  
  240. extern void *device_info_get(dev_t device);
  241.  
  242.  
  243.  
  244.  
  245. /* Support for INVENTORY */
  246. struct inventory_s;
  247. struct invplace_s;
  248. extern struct invplace_s invplace_none;
  249.  
  250. extern graph_error_t hwgraph_inventory_add(    vertex_hdl_t vhdl,
  251.                         int class,
  252.                         int type,
  253.                         major_t ctlr,
  254.                         minor_t unit,
  255.                         int state);
  256.  
  257. extern graph_error_t hwgraph_inventory_remove(    vertex_hdl_t vhdl,
  258.                         int class,
  259.                         int type,
  260.                         major_t ctlr,
  261.                         minor_t unit,
  262.                         int state);
  263.  
  264. extern graph_error_t hwgraph_inventory_get_next(vertex_hdl_t vhdl,
  265.                         struct invplace_s *place_p,
  266.                         struct inventory_s **inventory_p);
  267.  
  268.  
  269. extern int hwgraph_controller_num_get(dev_t);
  270. extern void hwgraph_controller_num_set(dev_t, int);
  271.  
  272.  
  273. /* Support for file systems */
  274.  
  275. extern graph_error_t hwgraph_connectpt_set(    vertex_hdl_t vhdl,
  276.                         vertex_hdl_t connectpt);
  277.  
  278. extern vertex_hdl_t hwgraph_connectpt_get(vertex_hdl_t vhdl);
  279.  
  280. extern void hwgraph_chmod(vertex_hdl_t vhdl, mode_t mode);
  281.  
  282. /* default permissions for various hwg node types */
  283. #define HWGRAPH_PERM_EXTERNAL_INT    0444
  284. #define HWGRAPH_PERM_TTY        0666
  285. #define HWGRAPH_PERM_TABLET        0644
  286. #define HWGRAPH_PERM_DIALS        0666
  287. #define HWGRAPH_PERM_KBD        0666
  288. #define HWGRAPH_PERM_MOUSE        0666
  289. #define HWGRAPH_PERM_CONSOLE        0644
  290. #define HWGRAPH_PERM_TPSC        0666
  291. #define HWGRAPH_PERM_MMSC_CONTROL    0600
  292.  
  293. /* Support for general topology manipulation */
  294.  
  295. extern graph_error_t hwgraph_vertex_name_get(    vertex_hdl_t vhdl,
  296.                         char *name_buf,
  297.                         uint name_length);
  298.  
  299. extern char *vertex_to_name(    vertex_hdl_t vhdl,
  300.                 char *name_buf,
  301.                 uint name_length);
  302.  
  303. extern vertex_hdl_t device_master_get(vertex_hdl_t vhdl);
  304.  
  305. extern cnodeid_t master_node_get(vertex_hdl_t vhdl);
  306.  
  307. extern cpuid_t cpuvertex_to_cpuid(vertex_hdl_t cpu_vhdl);
  308.  
  309. extern cnodeid_t nodevertex_to_cnodeid(vertex_hdl_t node_vhdl);
  310.  
  311.  
  312.  
  313. /*
  314.  * Support for "vpath".    A "vpath", or "vertex path" is an
  315.  * ordered list of vertices such that adjacent vertices in the
  316.  * vpath are connected by edges.
  317.  */
  318.  
  319. /* Maximum hwgraph vpath length (number of vertices) */
  320. #define HWGRAPH_VPATH_LEN_MAX          50
  321.  
  322. typedef struct hwgraph_vpath_s {
  323.         vertex_hdl_t vhdl_array[HWGRAPH_VPATH_LEN_MAX];
  324.         int pathlen;
  325. } *hwgraph_vpath_t;
  326.  
  327. typedef struct hwgraph_vpath_cursor_s {
  328.         hwgraph_vpath_t path;
  329.         int cursor;
  330. } *hwgraph_vpath_cursor_t;
  331.  
  332. extern hwgraph_vpath_t hwgraph_vpath_create(    vertex_hdl_t src,
  333.                         vertex_hdl_t sink);
  334.  
  335. extern void hwgraph_vpath_destroy(hwgraph_vpath_t vpath);
  336.  
  337. extern vertex_hdl_t hwgraph_vpath_vertex_get(hwgraph_vpath_cursor_t cursor);
  338.  
  339. extern void hwgraph_vpath_cursor_next(hwgraph_vpath_cursor_t cursor);
  340.  
  341. extern void hwgraph_vpath_cursor_prev(hwgraph_vpath_cursor_t cursor);
  342.  
  343. extern void hwgraph_vpath_cursor_init(    hwgraph_vpath_cursor_t cursor,
  344.                     hwgraph_vpath_t vpath);
  345.  
  346. extern void hwgraph_vpath_cursor_clone(    hwgraph_vpath_cursor_t source_cursor,
  347.                                   hwgraph_vpath_cursor_t dest_cursor);
  348.  
  349. extern hwgraph_vpath_cursor_t hwgraph_vpath_cursor_create(void);
  350.  
  351. extern void hwgraph_vpath_cursor_destroy(hwgraph_vpath_cursor_t cursor);
  352.  
  353. extern vertex_hdl_t mem_vhdl_get(vertex_hdl_t drv_vhdl);
  354.  
  355. extern int hwgraph_num_dev;
  356.  
  357. #endif /* _KERNEL */
  358.  
  359. #endif /* _HWGRAPH_H */
  360.